/**
 * 请求工具模块
 */
import axiso from 'axios'
import store from '@/store'

export const request = axiso.create({
  baseURL: 'https://conduit.productionready.io/' // 基础路径
})

request.interceptors.request.use(function (config) {
  // Do something before request is sent
  const user = store.state.user
  if (user) {
    config.headers.Authorization = `Token ${user.token}`
  }
  return config
}, function (error) {
  // Do something with request error
  return Promise.reject(error)
})
